/****************************************************************************
  From the Qt examples
****************************************************************************/

#ifndef CLIENT_H
#define CLIENT_H

#include <QDialog>
#include <QWidget>
#include <QTcpSocket>
#include <QTextEdit>
#include <QLineEdit>
#include <QSslError>
#include <QSslCertificate>
#include <QSslKey>
#include <QLinkedList>
#include <QLabel>
#include <QDialogButtonBox>
#include <QPushButton>
#include "../SimuHost/simuhost.h"

namespace Ui {
    class Client;
}

class Client : public QDialog
{
    Q_OBJECT

public:
    explicit Client(QWidget *parent = 0);
    ~Client();

private slots:
    void connectToServer();
    void readMessage();
    void displayError(QAbstractSocket::SocketError socketError);
    void enableConnectButton();
    void sendCMsg();
    void sendClientInfo(QString info);
    void connectedToTheServer();
    void disconnect();
    void setValues();
    void startSending();
    void stopSending();
    void updateHosts();

    void on_horizontalSlider_valueChanged(int value);

private:
    Ui::Client *ui;
    unsigned long long min, max;
    QLinkedList<SimuHost*> *hosts;

    QTcpSocket *tcpSocket;
    QString currentMessage;
    quint16 blockSize;
    QTimer *timer;
    int interval;
    int numUsers;
    bool connectedToServer;
    QString serverAddress;
    int serverPort;
};

#endif
